package com.mango.community.dao;

import com.mango.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

/**
 * @Author:  MangoCookieMilk
 * @Date:     2020/7/23 22:22
 * @Deprecated 这个注解的意思时声明一下这个类不推荐使用了
 */
@Mapper
@Deprecated
public interface LoginTicketMapper {

    /**
     * @param loginTicket
     * @return
     * 新增凭证
     * @Options(useGeneratedKeys = true,keyProperty = "id") 主键自动生成并且注入给id属性
     */
    @Insert({
            "insert into login_ticket (user_id,ticket,status,expired) " ,
             " values(#{userId},#{ticket},#{status},#{expired})"
    })
    @Options(useGeneratedKeys = true,keyProperty = "id")
    int insertLoginTicket(LoginTicket loginTicket);

    /**
     * @param ticket
     * @return
     * 查询凭证
     */
    @Select({
            "select id,user_id,ticket,status,expired ",
            " from login_ticket where ticket = #{ticket}"
    })
    LoginTicket selectByTicket(String ticket);

    /**
     * @param ticket
     * @param status
     * @return
     * 删除凭证，其实是修改状态，逻辑删除
     */
    @Update({
            "update login_ticket set status = #{status} ",
            " where ticket = #{ticket}"
    })
    int updateStatus(String ticket,int status);
}
